<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"/>
<title>用户登录页面</title>
</head>
<body>
     <div>
         <p>账号：<input type="text" name="username"/></p>
         <p>密码：<input type="text" name="password"/></p>
         <p><input type="submit" value="登录"/></p>
     </div>
     <p class="login-tip"></p>
     <script th:src="@{/js/plugins/jquery-1.11.1.js}"></script>
     
     <script>
   		//<![CDATA[
     	$(document).ready(function(){
     		$('input[type=submit]').bind('click' , function(){
     			var username = $('input[name=username]').val();
     			var password = $('input[name=password]').val();
     			var param = {
     				username : username,
     				password : password
     			}
     			$.ajax({
     				url : './ajaxLogin',
     				method : 'post',
     				async : true,
     				dataType : 'json',
     				data : param,
     				success : function(data){
     					if(data && data.status == 'ok'){
     						$('.login-tip').html(data.msg + ',用户token为:'+data.token);
     					}else{
     						$('.login-tip').html(data.msg);
     					}
     				},
     				error : function(xhr , error , status){
     					alert('发生了错误');
     				}
     			});
     		});
     	});
     	//]]>
     </script>
</body>
</html>